package com.hong.spring.transaction.service.impl;

import com.hong.spring.transaction.dao.UserRoleDao;
import com.hong.spring.transaction.entity.UserRole;
import com.hong.spring.transaction.service.IUserOrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Auther: csh
 * @Date: 2020/8/4 18:29
 * @Description:组织实现
 */
@Service
public class UserOrgServiceImpl implements IUserOrgService {

    @Autowired
    private UserRoleDao dao;

    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public void save(UserRole userRole) {
        dao.save(userRole);
    }

    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public void save2(UserRole userRole) {
        dao.save(userRole);
    }

    @Transactional(propagation = Propagation.MANDATORY)
    @Override
    public void save3(UserRole userRole) {
        dao.save(userRole);
    }

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    @Override
    public void save4(UserRole userRole) {
        dao.save(userRole);
        //throw new RuntimeException();
    }

    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    @Override
    public void save5(UserRole userRole) {
        dao.save(userRole);
        //throw  new RuntimeException();
    }

    @Override
    public void update(UserRole userRole) {
    }

    @Override
    public UserRole findById(Integer id) {
        return null;
    }
}
